﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class main : System.Web.UI.Page
{
    DataClassesDataContext db = new DataClassesDataContext();
    public int proflag = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        BindData();
    }
    private void BindData()
    {
        int userType = Convert.ToInt32(Session["type"].ToString());
        if (userType == 0)
        {
            string wbh = Session["wbh"].ToString();
            var FlagRes = (from p in db.StuInfo
                           where p.wbh == wbh
                           select p).ToList().First();
            if (System.IO.File.Exists(Server.MapPath("~/StuImage/" + FlagRes.sidfy + ".jpg")))
            {
                img_Stu.ImageUrl = "~/StuImage/" + FlagRes.sidfy + ".jpg";
            }
            else
            {
                img_Stu.ImageUrl = "~/Hbpu.jpg";
            }
            la_name.Text = "欢迎你，" + FlagRes.sname;
            var GradeRes = (from p in db.StuGradeInf
                            where p.wbh == wbh
                            select p.grade).ToList();
            int? stuflag = FlagRes.proflag;
            switch (stuflag)
            {
                case 0:
                    proflag = 1;
                    break;
                case 1:
                    proflag = 1;
                    break;
                case 2:
                    proflag = 2;
                    break;
                case 3:
                    if (FlagRes.zKZflag == 1)
                    {
                        proflag = 3;
                        break;
                    }
                    if (FlagRes.seatNo == null)
                    {
                        proflag = 3;
                    }
                    else
                    {
                        if (GradeRes.Count > 0)
                        {
                            proflag = 5;
                        }
                        proflag = 4;
                    }
                    break;
                case 4:
                    if (FlagRes.zKZflag == 1)
                    {
                        proflag = 3;
                        break;
                    }
                    proflag = 3;
                    break;
                case 5:
                    if (FlagRes.zKZflag == 1)
                    {
                        proflag = 3;
                        break;
                    }
                    proflag = 6;
                    break;
                case 6:
                    if (FlagRes.zKZflag == 1)
                    {
                        proflag = 3;
                        break;
                    }
                    proflag = 6;
                    break;
                default:
                    proflag = 0;
                    break;
            }   
        }
        else
        {
            pl_flow.Visible = false;
        }
    }
}